/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JOptionPane;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

/**
 *
 * @author Junior_eloy
 */
public class XML_Request {
    
    public void criarAlterar(String emailDestinatario, String emailRemetente, String emailAssunto, String emailMensagem){        
            Element request = new Element("Request");
            Document documento = new Document(request);
            Element email = new Element("Email");
            email.setAttribute("destinatario",String.valueOf(emailDestinatario)); 
            email.setAttribute("remetente", String.valueOf(emailRemetente));
            email.setAttribute("assunto", String.valueOf(emailAssunto));
            email.setAttribute("mensagem", String.valueOf(emailMensagem));
            request.addContent(email);
            XMLOutputter xout = new XMLOutputter();
            try {
                  FileWriter arquivo = new FileWriter(new File("../src/XML/Request.xml"));
                  xout.output(documento, arquivo);
                  JOptionPane.showMessageDialog(null, "Enviado com sucesso!");
            } catch (IOException e) {
                  e.printStackTrace();
            }    
    }
    
}
